// 封装定时器
function delay (time) {
  return new Promise((resolve, reject) => {
    setTimeout(resolve, time)
  })
}
export default {
  state: {
    userName: '李四'
  },
  getters: {
    getUserName: (state) => {
      return '我是' + state.userName
    }
  },
  mutations: {
    SET_NAME: (state, param) => {
      state.userName = 'hahah'
      return state.userName
    }
  },
  actions: {
    async setUsernameAfter5 ({ commit }, param) {
      await delay(5000)
      commit('SET_NAME', param)
    }
  }
}
